<template>
	<view>
		<dcp-scroller :isLoading="isLoading" @refresh="refresh">
		<view class="page_height_box">
		<view v-if="info==null">
			<zero-loading type="triangle"></zero-loading>
		</view>
		<view v-if="info!=null">
			<view class="info_box">
				<view class="info_title">
					{{info.title}}
				</view>
				<view class="desc_box">
					<jyf-parser :html="content" ref="article" :tag-style="tagStyle"></jyf-parser>
				</view>
			</view>
			<view style="height: 20rpx;"></view> 
		</view>
		</view>
		</dcp-scroller>
	</view>
</template> 
  
<script>
	import jyfParser from "@/components/jyf-parser/jyf-parser";
	import zeroLoading from "@/components/zero-loading/components/zero-loading/zero-loading.vue"
	export default {
		components: {
			jyfParser,
			zeroLoading
		},
		data() {
			return {
				isLoading:false,
				id:0,
				content:'',
				info:null,
				tagStyle: {
					img: 'display: block;width: 100%!important;height:auto!important;',
					p:'margin-bottom: 10rpx;line-height: 50rpx;'
				},
			};
		},
		onLoad(e) {
			var a =this
			a.id = e.id
			a.getArticle()
		},
		onPullDownRefresh(){
			var a = this
			a.getArticle()
		},
		methods:{
			refresh(){
				var a = this
				a.isLoading = true;
				setTimeout(()=>{
					a.getArticle()
				},200)
			},
			getArticle(){
				var a =this 
				a.globalajax('common/notice_info',{
					id:a.id
					},'GET',function(res) {
						console.log(res);
						uni.stopPullDownRefresh()
						uni.hideLoading()
						a.isLoading = false
						if(res.data.code==200){
							a.info = res.data.data
							const regex = new RegExp('<img', 'gi');
							var richtext = res.data.data.content
							richtext = richtext.replace(/<table[^>]*>/gi, '<table cellpadding="0" cellspacing="0" max-width="100%" border="1" style="font-size:12px;max-width:100%; text-align:left;text-indent: 0em;line-height:12px;">'); 
							a.content = richtext.replace(regex, `<img style="max-width: 100%;"`);	
						}else{	
							a.$showModal({
								title:'友情提示',
								content:res.data.msg,
								showCancel:false,
								confirmText:'我知道了',
								success: (res) => {
								}
							}); 
						}
					}
				);
			},
		}
	}
</script>

<style lang="scss">
page{
	background-color: #fff;
}
.info_box{
	width: 694rpx;
	padding: 0rpx 0rpx 30rpx 0rpx;
	margin: 0 auto;
	.info_title{
		font-size: 42rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 68rpx;
		letter-spacing: 0rpx;
		color: #333333;
	}
	.desc_box{
		font-size: 30rpx;
		line-height: 60rpx;
		letter-spacing: 0rpx;
		color: #333333;
		padding-top: 30rpx ;
		word-break: break-all;
		white-space:normal; 
		word-wrap:break-word;
		word-break:break-word;
	}
}

</style>
